/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Tactics;

import Game.NewGame;
import IO.models.PlayerConfig;
import Map.MapLevel;
import Monsters.Monster;
import java.io.FileNotFoundException;
import java.io.IOException;

/**
 *
 * @author insane
 */
public class Attack {

    private static Attack instance;

    public static Attack getInstance() {
        if (instance == null) {
            instance = new Attack();
        }
        return instance;
    }

    private Attack() {
    }

    public void action(Monster ms) throws FileNotFoundException, IOException, ClassNotFoundException {
        if (ms.getX() == MapLevel.getInstance().getMap().x && ms.getY() == MapLevel.getInstance().getMap().y) {
            return;
        }
        if (ms.getX() < MapLevel.getInstance().getMap().x) {
            if (!TackticUtils.checkMonsterMove(ms.getX() + 1, ms.getY(), ms)) {
                ms.setX(ms.getX() + 1);
            }
        }
        if (ms.getX() > MapLevel.getInstance().getMap().x) {
            if (!TackticUtils.checkMonsterMove(ms.getX() - 1, ms.getY(), ms)) {
                ms.setX(ms.getX() - 1);
            }
        }
        if (ms.getY() < MapLevel.getInstance().getMap().y) {
            if (!TackticUtils.checkMonsterMove(ms.getX(), ms.getY() + 1, ms)) {
                ms.setY(ms.getY() + 1);
            }
        }
        if (ms.getY() > MapLevel.getInstance().getMap().y) {
            if (!TackticUtils.checkMonsterMove(ms.getX(), ms.getY() - 1, ms)) {
                ms.setY(ms.getY() - 1);
            }
        }

    }
}
